﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.OleDb;
namespace HotelManager.Data_Access_Layer
{
    public class thongtinDAO:ConnectDAO
    {
        OleDbCommand cmd;
        OleDbConnection ketNoi = null;
        public void ThemTT()
        {
            try
            {
                cmd.CommandText = "insert into thongtin (tt_tenkhach,tt_tenviettat,tt_xephang,tt_diachi,tt_sodienthoai,tt_fax,tt_email,tt_website) values()";
                cmd.CommandType = CommandType.Text;
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close(); 
            }
        }
        public void HienThiTT()
        {
            try
            {
                cmd.CommandText = "select* from thongtin tt";
                cmd.CommandType = CommandType.Text;
                ketNoi = null; ketNoi = KetNoi();

                OleDbDataReader rd = cmd.ExecuteReader();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close(); 
            }
        }
        public void SuaTT()
        {
            try
            {
                cmd.CommandText = "update thongtin set tt_tenkhach= tt_tenviettat= tt_xephang= tt_diachi= tt_sodienthoai= tt_fax= tt_email= tt_website= where tt_tenviettat=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close(); 
            }
        }
        public void SuaTT_tenkhach()
        {
            try
            {
                cmd.CommandText = "update thongtin set tenkhach= where tt_tenviettat=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void SuaTT_tenviettat()
        {
            try
            {
                cmd.CommandText = "update thongtin set tt_tenviettat= where tt_tenviettat=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void SuaTT_xephang()
        {
            try
            {
                cmd.CommandText = "update thongtin set tt_xephang= where tt_tenviettat=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void SuaTT_diachi()
        {
            try
            {
                cmd.CommandText = "update thongtin set tt_diachi= where tt_tenviettat=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void SuaTT_sodienthoai()
        {
            try
            {
                cmd.CommandText = "update thongtin set tt_sodienthoai= where tt_tenviettat=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void SuaTT_fax()
        {
            try
            {
                cmd.CommandText = "update thongtin set tt_fax= where tt_tenviettat=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void SuaTT_email()
        {
            try
            {
                cmd.CommandText = "update thongtin set tt_email=  where tt_tenviettat=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void SuaTT_website()
        {
            try
            {
                cmd.CommandText = "update thongtin set tt_website= where tt_tenviettat=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void XoaTT()
        {
            try
            {
                cmd.CommandText = "delete from thongtin where tt_tenvietat= ";
                cmd.CommandType = CommandType.Text;
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close(); 
            }
        }
    }
}
